
// Source File Name:   EntityFactory.java

package com.sunwayhorizo.health.hl7.factories;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.common.MessageUtils;
import com.sunwayhorizo.health.hl7.common.VersionInfo;
import com.sunwayhorizo.health.hl7.datatypes.CE;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.SET_II;
import com.sunwayhorizo.health.hl7.rim.Container;
import com.sunwayhorizo.health.hl7.rim.Device;
import com.sunwayhorizo.health.hl7.rim.Hl7Entity;
import com.sunwayhorizo.health.hl7.rim.LanguageCommunication;
import com.sunwayhorizo.health.hl7.rim.LivingSubject;
import com.sunwayhorizo.health.hl7.rim.ManufacturedMaterial;
import com.sunwayhorizo.health.hl7.rim.Material;
import com.sunwayhorizo.health.hl7.rim.NonPersonLivingSubject;
import com.sunwayhorizo.health.hl7.rim.Organization;
import com.sunwayhorizo.health.hl7.rim.Person;
import com.sunwayhorizo.health.hl7.rim.Place;


// Referenced classes of package oracle.apps.ctb.hl7.factories:
//            DataTypeFactory, ReferenceModifier

public abstract class EntityFactory
{

    public static final String RCS_ID = "$Header: EntityFactory.java 1.0 2006/02/27 04:17:04 atomlins noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: EntityFactory.java 1.0 2006/02/27 04:17:04 atomlins noship $", "com.sunwayhorizo.health.facade.factories");
//    protected RimServiceBean session;
   
    protected DataTypeFactory dataTypeFactory;
    private static final String PARAMETER_KEY = "PARAM1";
    private static final String CAUSE_KEY = "CAUSE";
    private static final String NESTED_CODE = "HTB____";
    private static final String PARAMETER_MISSING_CODE = "CTB_NULL_PARAMETER";
    private static final String PARAMETER_MISSING_MESSAGE = "Invalid parameter was passed into this API. Required parameter [&PARAM1] was null.";
    private static final String NESTED_MESSAGE = "An error occurred while creating an instance of EntityFactory: &CAUSE";

    public static synchronized EntityFactory getInstance()
    {
        return new EntityFactoryImpl();
    }

//    public static synchronized EntityFactory getInstance(ServiceLocator servicelocator)
//    {
//        if(servicelocator == null)
//            throw newNullException("sl");
//        EntityFactoryImpl entityfactoryimpl;
//        try
//        {
//            entityfactoryimpl = new EntityFactoryImpl(servicelocator);
//        }
//        catch(Hl7Exception ctbexception)
//        {
//            throw newNestedException(ctbexception);
//        }
//        return entityfactoryimpl;
//    }

    public abstract Hl7Entity newHl7Entity(CS cs, CE ce, CS cs1, SET_II set_ii)
        throws Hl7Exception;
    
    /**
     * 创建电子病历分类
     *                 <br>
     * 作者              jinzw    <br>
     * 创建日期    2010-12-20  <br>
     * @param ce
     * @param cs
     * @param set_ii
     * @return
     * @throws Hl7Exception  Hl7Entity
     */
    public abstract Hl7Entity newHl7Entity(CE ce, CS cs, SET_II set_ii)
    throws Hl7Exception;

    public abstract Hl7Entity newHealthChart(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Organization newOrganization(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;
    
//    public abstract Organization newWorkingGroup(CE ce, CS cs, SET_II set_ii)
//    	throws Hl7Exception;
//    
//    public abstract Organization newHospitalOrg(CE ce, CS cs, SET_II set_ii)
//    	throws Hl7Exception;
//    
//    public abstract Organization newDepartment(CE ce, CS cs, SET_II set_ii)
//		throws Hl7Exception;

    public abstract Organization newPublicInstitution(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Organization newNation(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Organization newState(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Person newPerson(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;
    
    /**
     * 
    	* @Title: newPerson
    	* @Description: newPerson
    	* @param @param ce person cd 如患者ID等
    	* @param @param cs 
    	* @param @return
    	* @return Person    返回类型
    	* @throws Hl7Exception
    	* @firstAuthor jinzw
    	* @firstTime   2010-11-15 上午11:42:26
    	* @lastAuthor  jinzw
    	* @lastTime    2010-11-15 上午11:42:26
     */
    public abstract Person newPerson(CE ce, CS cs)
    throws Hl7Exception;
        
    public abstract LivingSubject newLivingSubject(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract NonPersonLivingSubject newNonPersonLivingSubject(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract NonPersonLivingSubject newAnimal(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract NonPersonLivingSubject newMicroorganism(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract NonPersonLivingSubject newPlant(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Material newMaterial(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Material newChemicalSubstance(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Material newFood(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract ManufacturedMaterial newManufacturedMaterial(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Container newContainer(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Container newHolder(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Device newDevice(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Device newCertificateRepresentation(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Device newImagingModality(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Place newPlace(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;
    
//    public abstract Place newRoom(CE ce, CS cs, SET_II set_ii)
//    	throws Hl7Exception;
//    
//    public abstract Place newBed(CE ce, CS cs, SET_II set_ii)
//		throws Hl7Exception;

    public abstract Place newCity(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Place newCountry(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Place newCounty(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Place newProvince(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Hl7Entity newResourceGroup(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Hl7Entity newGroup(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract LanguageCommunication newLanguageCommunication(CE ce, CS cs, SET_II set_ii)
        throws Hl7Exception;

    public abstract Hl7Entity makeReference(ReferenceModifier referencemodifier, CS cs, CE ce, CS cs1, SET_II set_ii, int i)
        throws Hl7Exception;

    private static RuntimeException newNullException(String s)
    {
        String as[] = {
            "PARAM1"
        };
        String as1[] = {
            s
        };
        String s1 = MessageUtils.getMessage("Invalid parameter was passed into this API. Required parameter [&PARAM1] was null.", as, as1);
        return new NullPointerException(s1);
    }

    private static RuntimeException newNestedException(Hl7Exception ctbexception)
    {
        String as[] = {
            "CAUSE"
        };
        String as1[] = {
            ctbexception.getMessage()
        };
        String s = MessageUtils.getMessage("An error occurred while creating an instance of EntityFactory: &CAUSE", as, as1);
        return new RuntimeException(s);
    }

    public EntityFactory()
    {
    }

}
